[pull] main from vercel:main#305
Merged
Merged
Conversation
…#1491) * feat: allow start() to be called directly inside workflow functions Add 'use step' to start() so it can be called directly from workflow code. The SWC compiler strips the function body in workflow mode and replaces it with a step proxy. When called from a workflow: 1. The workflow function reference is serialized via WorkflowFunction reducer (serializes { workflowId }) 2. start() executes in the step context with full Node.js access 3. The returned Run is serialized via WORKFLOW_SERIALIZE and deserialized back in the workflow VM 4. Run getters (.status, .returnValue, etc.) are 'use step' getters that each execute as separate steps Also re-exports start from @workflow/core/runtime/start in api-workflow.ts instead of using a throwing stub, adds e2e tests for startFromWorkflow (with hook communication) and fibonacciWorkflow (recursive composition). * fix(next): don't copy package step files in deferred builder to avoid duplicate classes Files belonging to packages (detected by walking up to find a package.json with a name field) are imported via relative path instead of being copied to __workflow_step_files__/. Copying creates a second module instance which breaks JS native private field (#) brand checks when the runtime creates instances from one copy and the step handler accesses fields from the other. * fix(next): only skip copying package files that are serde classes, not all package step files Regular package step files (like fetch) must still be copied to ensure the SWC loader registers them. Only serde class files from packages are excluded from copying since those define classes with JS native private fields (#) that break when duplicated. * fix(next): generate thin wrappers for package serde step files instead of full copies For package files that define serde classes (like Run), generate a thin wrapper that imports the original class and registers steps/classes from the manifest. This avoids duplicating the class definition (which breaks JS native private field brand checks) while still registering all step functions and the class in the serialization registry. Regular package step files (like fetch) are still copied as before. * fix(next): use forceStepModeFiles to transform package serde files in step mode Instead of copying package serde+step files (which creates duplicate classes with #private brand check issues) or generating fragile wrappers, add the original file paths to a shared forceStepModeFiles set. The loader checks this set and transforms those files in step mode directly, so the SWC plugin generates proper step registrations on the original class — no duplication, no reimplemented registration logic. * fix(next): use step mode for all files with step/serde patterns, not just copies The loader now selects step mode for any file that has 'use step' directives or serde patterns, regardless of whether it's a deferred step copy. Step mode is a superset of client mode — the only addition is step registry IIFEs, which are harmless for non-step consumers. This means package serde+step files (like Run) no longer need to be copied to get step registrations. They're imported directly in the step route and the loader transforms the original file in step mode. One class instance, no duplication, no wrapper generation. --------- Co-authored-by: Nathan Rajlich <n@n8.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )